<%--
  检查提交的答案是否正确，正确，则让用户输入新密码
  提交新密码给userPasswordFind4.jsp处理
--%>
<%@ page import="com.dsj.dao.CustomerDao" %>
<%@ page import="com.dsj.entity.CustomerEntity" %><%--
  Created by IntelliJ IDEA.
  User: Tec
  Date: 2023/12/14
  Time: 9:06
  To change this template use File | Settings | |Editor | File and Code Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>输入新密码</title>
</head>
<body>
<%
    CustomerDao customerDao = new CustomerDao();  // 创建CustomerDao对象

    request.setCharacterEncoding("utf-8");  // 设置请求的字符编码为utf-8

    String result = request.getParameter("result").trim();  // 获取并去除result参数的前后空格

    CustomerEntity user = (CustomerEntity) session.getAttribute("user");  // 从session中获取user属性，并转换为CustomerEntity类型

    String name = request.getParameter("name").trim();  // 获取并去除name参数的前后空格

%>
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" height="100">
            <jsp:include   page="../common/head.jsp" flush="true" />
        </td>
    </tr>

    <tr>
        <td width="300" valign="top" bgcolor="#F5F5F5">
            <!--左侧01-->
            <jsp:include page="../common/left.jsp" flush="true" />
        </td>

        <td width="724" align="center" valign="top" bgcolor="#FFFFFF">

            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
                <tr>
                    <td bgcolor="#FFFFFF" align="center">
                        <img src="<%=request.getContextPath() %>/images/systemImages/fg2.jpg" width="752" height="45">
                        <%
                            //if(user==null||user.equals(""))
                            if(!result.equals(user.getPasswordHintAnswer()))
                            {
                        %>
                        <p><strong>答案不正确,请重新输入！！！</strong></p>
                        <meta http-equiv="refresh" content="2;URL=userPasswordFind2.jsp?name=<%=name%>">
                        <%}else{%>
                        <p><strong>输入新密码</strong></p>
                        <form name="form3" method="post" action="./userPasswordFind4.jsp?id=<%=user.getId()%>" onSubmit="return checkEmpty(form3)">
                            <table width="298"  border="0" cellspacing="0" cellpadding="0" bordercolor="#FFFFFF" bordercolordark="#819BBC" bordercolorlight="#FFFFFF">
                                <tr>
                                    <td width="105" height="35">
                                        <div align="right">请输入新的密码：</div></td>
                                    <td width="187"><div align="center">
                                        <input type="password" name="password">
                                    </div></td>
                                </tr>
                                <tr>
                                    <td width="105" height="35">
                                        <div align="right">确认密码：</div></td>
                                    <td width="187"><div align="center">
                                        <input type="password" name="passwordOne">
                                    </div></td>
                                </tr>
                            </table>
                            <br>
                            <input type="image" class="input1"  src="<%=request.getContextPath() %>/images/systemImages/save.jpg" width="51" height="20">
                            &nbsp;&nbsp;
                            <a href="#" onClick="javascript:form3.reset()"><img src="<%=request.getContextPath() %>/images/systemImages/clear.gif"></a>
                            &nbsp;&nbsp;
                            <a href="#" onClick="javasrcipt:history.go(-1)"><img src="<%=request.getContextPath() %>/images/systemImages/back.gif"></a>
                        </form>
                        <%}%>
                    </td>
                </tr>
            </table>

        </td>

    <tr>
        <td colspan="2">
            <jsp:include page="../common/statusBarNavigation.jsp"
                         flush="true" />
        </td>
    </tr>
</table>
<script language="javascript">
    function checkEmpty(form){
        for(i=0;i<form.length;i++){
            if(form.elements[i].value==""){
                alert("表单信息不能为空");
                return false;
            }
        }
        if(form.password.value != form.passwordOne.value){
            window.alert("您两次输入的密码不一致，请重新输入");
            return false;
        }
    }

</script>
</body>
</html>
